﻿// =================================================================== 
// 模块说明
//====================================================================
// 创建时间：2019-07-05 15:07:54
// 负责人：Sushee
// ===================================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq.Expressions;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

namespace OF.Component.DAL
{
	
	/// <summary>
	/// 数据访问层
	/// </summary>	
	internal partial class WxOfficialAccountMenu
	{		
    
        /// <summary>
    	/// 根据断言条件获取单个
    	/// </summary>
        public WxOfficialAccountMenuInfo QuerySingle(Expression<Func<WxOfficialAccountMenuInfo, bool>> predicate)
	    {
            return SQLServerProvider.CreateObject(ConnectionStringKey, predicate);
        }
        /// <summary>
    	/// 根据断言条件获获取列表
    	/// </summary>
	    public IList<WxOfficialAccountMenuInfo> QueryList(Expression<Func<WxOfficialAccountMenuInfo, bool>> predicate)
	    {
	        return SQLServerProvider.CreateList(ConnectionStringKey, predicate);
	    }

        /// <summary>
        /// 删除父级下的所有子菜单
        /// </summary>
        /// <param name="menuId"></param>
        /// <returns></returns>
        public bool DelMenuByParentId(int parentId)
        {
            string sql = "update WxOfficialAccountMenu set IsActive=0 where MenuParentId=@ParentID and isactive=1";
            Database db = DatabaseFactory.CreateDatabase(this.ConnectionStringKey);
            DbCommand dbc = db.GetSqlStringCommand(sql);
            db.AddInParameter(dbc, "@ParentID", DbType.Int32, parentId);
            return db.ExecuteNonQuery(dbc) > 0;
        }

    }
	
}